<%@ page import="vo.User" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生成绩管理系统v1.0</title>
</head>
<body>
欢迎您：${user.uname}(${user.uid})</br>
<a href="lecUI.jsp"> 回到上一页 </a></br>
<h1>录入课程成绩</h1>
<%
    if(session.getAttribute("scid")==null){
        session.setAttribute("scid",request.getParameter("scid"));
    }
    else{
        if(request.getParameter("scid")!=null)
            session.setAttribute("scid",request.getParameter("scid"));
    }
%>

<c:if test="${empty gradeList}">
    <%
        request.getRequestDispatcher("/askScore").forward(request, response);
    %>
</c:if>

<table border="1" cellpadding="10">
<tr>
    <td>选课编号</td>
    <td>学生学号</td>
    <td>学生姓名</td>
    <td>课程名称</td>
    <td>班级名称</td>
    <td>成绩</td>
    </br>
</tr>
<c:forEach items="${gradeList}" var="grade">
    <tr>
        <td>${grade.scid}</td>
        <td>${grade.sid}</td>
        <td>${grade.uname}</td>
        <td>${grade.cname}</td>
        <td>${grade.clname}</td>
        <c:if test="${grade.grade==-100}">
            <td bgcolor="#FF0000">尚未打分</td>
        </c:if>
        <c:if test="${grade.grade!=-100}">
            <td>${grade.grade}</td>
        </c:if>

        </br>
    </tr>
</c:forEach>
</table>
<%
    String s=request.getParameter("scid");
%>
<form action="/addScore?scid=<%=s%>" name="f1">
    <tr>
        <td>请输入学生ID:</td>
        <td><input type="text" name="sid" id="sid"></td>
    </tr>
    <tr>
        <td>请输入学生成绩</td>
        <td><input type="text" name="ggrade" id="ggrade"></td>
    </tr>
    <%--<input type="hidden" name="scid" value=<%=request.getParameter("scid")%> >--%>
    <input type="submit" value="提交" onclick="verifyScore()">
</form>
<%
    if(request.getParameter("res")!=null)
    {
        if(request.getParameter("res").equals("1"))
        {
            out.println("<alert>\n" +
                    "    插入成绩成功\n" +
                    "</alert>");
        }
        else
        {
            out.println("<alert>\n" +
                    "    插入成绩失败\n" +
                    "</alert>");
        }
    }
%>
</body>
</html>
